#!/bin/bash
Install_gitlab(){
    . ./var
    . ./Tmpdir
    # Check if the software is installed 
    [ -f /opt/gitlab/embedded/service/gitlab-rails/VERSION ] && cat /opt/gitlab/embedded/service/gitlab-rails/VERSION && echoRed "gitlab已经安装，即将退出" && exit 6
    [ -d /opt/gitlab ] && echoRed "gitlab已经安>装，即将退出" && exit 4
    which gitlab-ctl &> /dev/null && echoRed "gitlab已经安>装，即将退出" && exit 5
    gitlab-ctl status &> /dev/null && echoRed "gitlab已经安>装，即将退出" && exit 7

    # Install dependency package
    yum install curl policycoreutils policycoreutils-python openssh-server openssh-clients postfix  libsemanage-static libsemanage-devel -y


    # Call the function Tmpdir
    Tmpdir
    cd $dir && wget -V &> /dev/null || yum -y install wget

    # Download and install the software
    wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.8.9-ce.0.el7.x86_64.rpm
    yum -y install gitlab-ce-12.8.9-ce.0.el7.x86_64.rpm

    # Boot up
    systemctl enable gitlab-runsvdir.service
}
